﻿<cfsilent>
	<cfscript>
		
		propertyAdvice = getProperty("serviceFactory").getBean("studentPropertyAdvice");
		
		event.setArg("pageTitle", "成绩管理 - 成绩通知单打印");
		
		passArgs = structNew();
		
		currentTab = event.getArg("TabID", "labSearch");
		
		/*所有学生类型信息*/
		sql = "SELECT code_id, name FROM i_code_info where field_id = '4' order by length(name), name";
		
		queryObj = new Query( datasource=application.dnsSlave );
		
		rs_code = queryObj.execute( sql=sql ).getResult();
		
		/*所有学期信息*/
		sql = "SELECT term_id, academic_year, academic_term FROM t_term WHERE substr(academic_year,1,4) < " & year(now())+2 & "order by term_id desc";
		
		queryObj = new Query( datasource=application.dnsSlave);
		
		rs_term = queryObj.execute( sql=sql ).getResult();
		
		
		/* 搜索学生档案 */
		studyType = event.getArg("ST");
		termId = event.getArg("TID");
		

		rs_student = queryNew("stu_id");
		
		if ( len(studyType) && len(termId) ) {
			
			sql = "SELECT 
						 t_student.stu_id, t_student.stu_name, t_student.stu_name_english, stu_sex, t_student_status.st_id  
					FROM 
						 t_student 
						 INNER JOIN t_student_status ON t_student_status.stu_id = t_student.stu_id 
					WHERE t_student_status.st_id = :codeId 
						AND EXISTS(
						SELECT 1 FROM t_student_mark where t_student_mark.stu_id = t_student.stu_id and t_student_mark.term_id = :termId 
					)
					ORDER BY 
						 t_student.stu_name ";
			
			queryObj = new Query( datasource=application.dnsSlave );
			queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_varchar" );
			queryObj.addParam( name="codeId", value=studyType, cfsqltype="cf_sql_char" );
			
			rs_student = queryObj.execute( sql=sql ).getResult();
			
			
			/*所选类型*/
			sql = "SELECT name FROM i_code_info where code_id = :codeId";
			
			queryObj = new Query( datasource=application.dnsSlave );
			queryObj.addParam( name="codeId", value=studyType, cfsqltype="cf_sql_integer" );
			
			rs_codeEntity = queryObj.execute( sql=sql ).getResult();
			
			/*所有学期信息*/
			sql = "SELECT term_id, academic_year, academic_term FROM t_term where term_id = :termId ";
			
			queryObj = new Query( datasource=application.dnsSlave);
			queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
			
			rs_termeNTITY = queryObj.execute( sql=sql ).getResult();
						
		}

		
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('DEFAULT_EVENT')#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">成绩数据维护</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 application"></i>打印成绩通知单
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labSearch">class="active"</cfif> id="labSearch" tabTarget="Search">搜索学生</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				
				<div id="Search" class="tabContent">
					
					<form id="formSearch" onSubmit="javascript:return processVerfiyForm('formSearch');" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('studentGradeMark')#</cfoutput>">
						<input type="hidden" name="TabID" value="labSearch" />
						
						<div class="label">
							<b>学生类型</b>
                                   <select name="st">
                                        <cfloop query="rs_code">
                                             <option <cfif studyType eq rs_code.code_id>selected="selected"</cfif> value="<cfoutput>#rs_code.code_id#</cfoutput>"><cfoutput>#rs_code.name#</cfoutput></option>
                                        </cfloop>
                                   </select>
                             
						</div>
                              <div class="label">
							<b>开设学期</b>
                                   <select name="TID">
                                   	<cfif termId neq "">
                                                  <cfloop query="rs_term">
                                                       <option <cfif termId eq rs_term.term_id>selected="selected"</cfif> value="<cfoutput>#rs_term.term_id#</cfoutput>"><cfoutput>#rs_term.academic_year#</cfoutput>学年第<cfoutput>#rs_term.academic_term#</cfoutput>学期</option>
                                                  </cfloop>
                                        	<cfelse>
                                            		<cfloop query="rs_term">
                                                    	<option <cfif event.getArg("termId") eq rs_term.term_id>selected="selected"</cfif> value="<cfoutput>#rs_term.term_id#</cfoutput>"><cfoutput>#rs_term.academic_year#</cfoutput>学年第<cfoutput>#rs_term.academic_term#</cfoutput>学期</option>
                                                  </cfloop>
                                        </cfif>
                                   </select>
                             
						</div>
						<hr/>
						<div class="lable">
							<input class="button1" type="submit" value="搜索" />
						</div>
					</form>
					
					 <cfif rs_student.recordCount>

                    
                              <cfset row = 0 />
                              <table class="UIEditable">
                                   <thead>
                                        <tr>
                                             <td width="18"></td>
                                             <td>开课学期</td>
                                             <td>学生学号</td>
                                             <td>英文名</td>
                                             <td>中文名</td>
                                             <td>性别</td>
                                             <td>学生类型</td>
                                             <td>操作</td>
                                        </tr>
                                   </thead>
                                   <tbody>
                                        <cfloop query="rs_student">
                                        
                                           
                                             <cfset row++ />
                                             
                                             <cfset structInsert(passArgs, "STU", rs_student.stu_id, true) />
                                             <cfset structInsert(passArgs, "TID", termId, true) />
                                             
                                             
                                             <tr class="editRows">
                                                  <td class="index"><cfoutput>#row#</cfoutput></td>
                                                  <td><cfoutput>#rs_termEntity.academic_year#</cfoutput>学年第<cfoutput>#rs_termEntity.academic_term#</cfoutput>学期</td>
                                                  <td><cfoutput>#rs_student.stu_id#</cfoutput></td>
                                                
                                                  <td><cfoutput>#rs_student.stu_name_english#</cfoutput></td>
                                                  <td><cfoutput>#rs_student.stu_name#</cfoutput></td>
                                                  <td><cfif rs_student.stu_sex eq "1">男<cfelse>女</cfif></td>
                                                  <td><cfoutput>#rs_codeEntity.name#</cfoutput></td>
                                                  <td><a class="stat print" title="打印成绩通知单" href="<cfoutput>#buildURL("gradeScorePrint",passArgs)#</cfoutput>" target="_blank"></a></td>
                                                      
                                             </tr>
                                        </cfloop>
                                   </tbody>
                              </table>
                              
                                   
                    
                  		</cfif>
					
				</div>
				
			</div>
		</li>
	</ul>
</div>